home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
-
- int main(int argc, char *argv[])
- {
- int buf;
- FILE *file, *fileII;
-
- if (argc > 1)
- {
- if ((file = fopen(argv[1], "r")) == NULL)
- {
- printf("Couldn't open the input text file...\n");
- fclose(file);
- exit(20);
- }
- if ((fileII = fopen("T:Temp.txt", "w")) == NULL)
- {
- printf("Couldn't open the Temporary text file...\n");
- fclose(file);
- fclose(fileII);
- if (!remove("T:Temp.txt")) printf("Error removing temporary file...\n");
- exit(20);
- }
- do
- {
- buf = getc(file);
- if ((buf != EOF) && (buf != '\r')) putc(buf, fileII);
- }
- while (buf != EOF);
- fclose(file);
- fclose(fileII);
-
- if ((file = fopen(argv[1], "w")) == NULL)
- {
- printf("Couldn't reopen the input text file...\n");
- fclose(file);
- exit(20);
- }
- if ((fileII = fopen("T:Temp.txt", "r")) == NULL)
- {
- printf("Couldn't reopen the Temporary text file...\n");
- fclose(file);
- fclose(fileII);
- if (!remove("T:Temp.txt")) printf("Error removing temporary file...\n");
- exit(20);
- }
- do
- {
- buf = getc(fileII);
- if (buf != EOF) putc(buf, file);
- }
- while (buf != EOF);
- fclose(file);
- fclose(fileII);
-
- if (!remove("T:Temp.txt"))
- {
- printf("Error removing temporary file...1\n");
- exit(5);
- }
- }
- else {printf("This Command has one argument: (textin)...\n"); exit(10);}
- exit(0);
- }
-